import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
import { EntityBase } from "@/common/entities/entity.base";
import { Menu } from "src/modules/menu/entities/menu.entity";
import { RoleApi } from "@/modules/role-api/entities/role-api.entity";


@Entity()
export class Api extends EntityBase {
    @PrimaryGeneratedColumn()
    id: number;
    
    @Column({ type: "varchar", comment: "接口名称", nullable: false })
    apiName: string;
    
    @Column({ type: "varchar", comment: "接口路径", nullable: false })
    apiUrl: string;
    
    @Column({ type: "varchar", comment: "请求方式", nullable: false, default: "GET" })
    method: string;
    
    @Column({ type: "int", comment: "菜单id", nullable: false })
    menuId: number;
    
    @ManyToOne(() => Menu, (menu) => menu.api)
    menu: Menu;
    
    @OneToMany(() => RoleApi, (roleApi) => roleApi.api)
    roleApi: RoleApi[];
}

